package untils

import (
	"fmt"
	"house-src/basic/config"
	"log"
	"math/rand"
	"time"
)

// 计算服务难度系数
func CountDifficulty(address string, area int) float64 {
	//指标
	index := rand.Intn(10)

	sprintf := fmt.Sprintf("服务地址:%s,服务面积:%d,服务难度系数:%.2f", address, area, float64(area*index)/100)
	log.Println(sprintf)

	return float64(area*index) / 100
}

// 计算价格
func CountOrder(classType string, area int, duration float64) float64 {
	//服务地址

	//服务面积
	area = area

	//基础价
	base := 30.0
	//面积费
	areaPrice := 15.0
	//时长费
	durationPrice := 10.0

	//服务类型
	switch classType {
	case "日常保洁":
		base = float64(area)*areaPrice + base + 10 + duration*durationPrice
	case "深度清洁":
		base = float64(area)*areaPrice + base + 20 + duration*durationPrice
	case "开荒保洁":
		base = float64(area)*areaPrice + base + 30 + duration*durationPrice
	default:
		base = float64(area)*areaPrice + base + duration*durationPrice
	}

	//缓存
	config.Rdb.Set(config.Ctx, "classType"+classType, base, time.Hour*1)

	return base

}
